Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTful APIs + Clean URLs for cologne #117

Open
drdhaval2785 opened this issue Apr 15, 2017 · 60 comments
Open

RESTful APIs + Clean URLs for cologne #117

drdhaval2785 opened this issue Apr 15, 2017 · 60 comments
Assignees
Labels
enhancement New website features
Milestone

Comments

@drdhaval2785
Copy link
Contributor

drdhaval2785 commented Apr 15, 2017

https://api.github.com/repos/drdhaval2785/siddhantakaumudi

Please look at the API structure of various links mentioned on this page. It is extremely intuitive.
Can we design similar APIs for cologne where the URL itself sends necessary information and we send back the response JSON?

UPDATE

https://github.com/sanskrit-lexicon/Cologne/blob/master/api/apidoc.md is the place where I will be tracking various existing Cologne APIs and their rewrite rules.

@funderburkjim
Copy link
Contributor

funderburkjim commented Apr 15, 2017

These urls are of a style that I have seen with various Python web frameworks, such as Django and flask.

http://example.com/value1/value2/value3

It may also be a feature of Ruby on Rails web framework, which may be what runs GitHub.

It is probably an art to making such urls 'intuitive' to the user of a website.

Essentially, the servers for these urls send the url to a routing function, which interprets the
sequence of values and acts accordingly.

Another style of restful api is to use parameters:

http://example.com?parm1=value1&parm2=value2&parm3=value3

This is the style that I know how to implement with php; and all the restful interfaces at Cologne sanskrit-lexicon site are of this form.

It might be that using Apache rewrite rules (e.g. by an '.htaccess file reference) would be a way to turn the first style into the second style.

Or maybe (probably) there is some way that php has to directly handle urls of the first type.
Maybe you can do some research and find a reference on this.

The sending back of response in JSON is not particularly hard, whichever style of url is used. Since
JSON definition includes not only Objects {'x':'y', 'z':'w'}, arrays [x1, x2, x3], but also constants
'X', 274, etc ==== We can say that Cologne restful apis already return JSON: namely, in the form (for the most part) of string constants representing HTML (usually).

Still a third way of sending parameters is to send JSON to the server, e.g.

{"parm1":"value1", "parm2":"value2"...}

This is easy with JQuery .ajax

If I'm not mistaken, this latter JSON way of sending from browser to server is the form @juhnowski
favors.

Probaby the first thing that needs to be done is to have an inventory of all the restful (in style 2) interfaces that currently exist at Cologne; and a specification of the type of data returned. This would serve as a reference point for designing a better API, for whichever restful style we move towards. This will also give a basis for identifying what kinds of JSON objects (rather than just html string constants) the server should return in response to the restful inputs.

@drdhaval2785 drdhaval2785 changed the title RESTful APIs for cologne RESTful APIs + Clean URLs for cologne Apr 15, 2017
@drdhaval2785
Copy link
Contributor Author

Just to get discussion started on two APIs, I have scribbled two such itens

  1. Suggest word based on prefix, suffix, substring

tmp_394-20170415_1024422124857691

@drdhaval2785
Copy link
Contributor Author

drdhaval2785 commented Apr 15, 2017

  1. Search a particular entry

entries/dictcode/inputtransliteration/headword/outputtransliteration/ignoreaccent

tmp_394-20170415_102451337383365

@gasyoun
Copy link
Member

gasyoun commented Apr 15, 2017

This is the style that I know how to implement with php; and all the restful interfaces at Cologne sanskrit-lexicon site are of this form.

From SEO - it's worst possible way. And for the user it's no good as well, right.

Or maybe (probably) there is some way that php has to directly handle urls of the first type.
Maybe you can do some research and find a reference on this.

Do not think so. I usually do with mod rewrite. But I do not deal with APIs.

@drdhaval2785
Copy link
Contributor Author

drdhaval2785 commented Apr 15, 2017

Regarding implementation of point 1

.htaccess file

RewriteEngine on
RewriteRule ^suggest/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*) http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc2/query.php?word=&lastLnum=0&max=$5&filter=deva&regexp=exact&scase=true&sword=$4&sregexp=$2&transLit=$3&outopt=outopt4&swordhw=hwonly

http://localhost/apitrial/suggest/PW/prefix/slp1/Dava/100
gave result like this

-1#

1 धवनी
2 धवर
3 धवल
4 धवलगिरि
5 धवलगृह
6 धवलता
7 धवलनिबन्ध
8 धवलपक्ष
9 धवलपुराणसमुच्चय
10 धवलमुख
11 धवलमृत्तिका
12 धवलय्
13 धवलाय्
14 धवलाष्टक
15 धवलिमन्
16 धवली
17 धवलेतरतण्डुल
18 धवलोत्पल

@funderburkjim
The only drawback seems to be the capital PW in the whole url. It is a bit difficult to modify it to lowercase in rewrite rule. Jim can handle it in backend. The dictionary code passed in small letters can be converted to capital on his part in PHP.

@drdhaval2785
Copy link
Contributor Author

So it seems easily doable to use more user friendly URLs with existing infrastructure (with very less modification too).
Two lines of .htaccess file is the only code I wrote for this result to occur.

@drdhaval2785
Copy link
Contributor Author

drdhaval2785 commented Apr 15, 2017

Regarding implementation of API no. 2 -

.htaccess file

RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*) http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$3&filter=$4&noLit=off&transLit=$2

http://localhost/apitrial/entries/PW/slp1/citra/deva/ignoreaccent

gave following result

 चित्र

 चित्र [L=39963] [p= 2228-1]
— 1)  Adj.  ( f.  )
  — a) augenfällig , sichtbar , ausgezeichnet.
  — b) hell , licht , hellfarbig. °म्  Adv.   Ṛv.1,71,1.6,65,2. 
  — c) hell , vernehmlich (von Tränen).  [Page2.228-2] 
  — d) verschiedenfarbig , bunt , scheckig. Das , was die Verschiedenfarbigkeit bildet , im  Instr.  oder im Comp. vorangehend.
  — e) bewegt (vom Meere).
  — f) mannichfaltig , verschieden , allerlei. °म् und चित्र°  Adv. 
  — g) qualificirt , mit verschiedenen Martern verbunden (Strafe , Hinrichtung)  203,26.  °म्  Adv.  unter verschiedenen Martern.
  — h) wunderbar.  Spr.5087. 
  — i) das Wort चित्र enthaltend.
— 2)  m. 
  — a) *Buntheit.
  — b) ®*Plumbago_zeylanica.
  — c) ®*Ricinus_communis.
  — d) ®*Jonesia_Asoka.
  — e) eine Form Jama's.
  — f) N.pr.
    — α) verschiedener Männer (parox.  Ṛv.). 
    — β) *eines Gandharva  Gal. 
— 3)  f. 
  — a)  Sg.  und  Pl.  das 12te (später das 14te) Mondhaus.
  — b) *eine Schlangenart.
  — c) Bez. verschiedener Pflanzen  Ḱaraka.7,12.  ( = द्रवन्ती). Nach den Lexicographen: ®Salvinia_cucullata , ®Cucumis_maderaspatanus , Koloquinthe , ®Ricinus_communis , ®Croton_polyandrum oder Tiglium , Myrobalanenbaum , ®Rubia_Munjista und ein best. Gras ( गण्डदूर्वा).
  — d) Bez. verschiedener Metra.
  — e) ein best. Saiteninstrument  S.s.s.185. 
  — f) ein best. Mûrḱhanâ  S.s.s.30. 
  — g) *Schein , Täuschung.
  — h) N.pr.
    — α) *einer Apsaras.
    — β) verschiedener Frauen.
    — γ) eines Felsens.
    — δ) *eines Flusses.
— 4)  n. 
  — a) eine helle , glänzende oder farbige Erscheinung , ein in die Augen fallender Gegenstand , ein funkelndes Geschmeide , Schmuck.
  — b) *verschiedenfarbiges oder verschiedengestaltetes Gehölz.
  — c) Fleck , macula.
  — d) *Sectenzeichen auf der Stirn.
  — e) *der weisse Aussatz.
  — f) Bild , Gemälde , Malerei. Am Ende eines  adj.  Comp.  f.   Megh.64. 
  — g) *buntheit.
  — h) eine ungewöhnliche Erscheinung , Wunder. Mit folgenden यदि , यद् oder *Fut. चित्रम् als Ausruf so v.a. o. Wunder  123,22.134,29.174,11.  Spr.7811. 
  — i) *der Luftraum , Himmel.
  — k) Bez. verschiedener Arten , künstliche Verse u.s.w. in Form von allerlei Figuren durch Nichtwiederholung wiederkehrender Silben oder Wörter in abgekürzter Weise künstlich für das Auge darzustellen  Kâvjapr.9,8.  Wort- und Lautspiel.

@drdhaval2785
Copy link
Contributor Author

@funderburkjim and @gasyoun

After experimenting a bit with Cologne server APIs, I feel that the work towards RESTful APIs + Clean URLs is just a bit of mod rewrite modules + some regex magic.
So it is time to define all parameters and output format for proper APIs.

Jim may like to list the current APIs (Long URL types).
I will convert it to some user friendly APIs via rewrite.

@drdhaval2785
Copy link
Contributor Author

drdhaval2785 commented Apr 15, 2017

It might be that using Apache rewrite rules (e.g. by an '.htaccess file reference) would be a way to turn the first style into the second style.

And it turns out to be damn easy.

Server needs these two commands to enable mod rewrite

a2enmod rewrite
service apache2 restart

Then the following .htaccess file needs to be put in api folder in Cologne server.

RewriteEngine on
RewriteRule ^suggest/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*) http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc2/query.php?word=&lastLnum=0&max=$5&filter=deva&regexp=exact&scase=true&sword=$4&sregexp=$2&transLit=$3&outopt=outopt4&swordhw=hwonly
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*) http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$3&filter=$4&noLit=off&transLit=$2

@gasyoun
Copy link
Member

gasyoun commented Apr 15, 2017

http://localhost/apitrial/entries/PW/slp1/citra/deva/ignoreaccent

I would go for http://www.sanskrit-lexicon.uni-koeln.de/MD/citra/SDI/
instead of http://www.sanskrit-lexicon.uni-koeln.de/scans/MDScan/2014/web/webtc/indexcaller.php

/SDI/

These service pages we will close for indexation. S for SLP1, D for devanagari, I for ignore accents.

@drdhaval2785
Copy link
Contributor Author

I would go for http://www.sanskrit-lexicon.uni-koeln.de/MD/citra/SDI/

Doable, but seems non-intuitive.

Currently making a list of existing APIs at Cologne.

@funderburkjim
Copy link
Contributor

@drdhaval2785 Good research on htaccess.

I tried one of your examples at Cologne as follows:

RewriteEngine On    # Turn on the rewriting engine
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*) http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$3&filter=$4&noLit=off&transLit=$2```

Usage example:
http://www.sanskrit-lexicon.uni-koeln.de/apitest/entries/PW/slp1/citra/deva/ignoreaccent

This shows:

  • The Cologne sanskrit-lexicon Apache server is set up to handle rewrites
  • This may be done within .htaccess file

@drdhaval2785
Copy link
Contributor Author

https://github.com/sanskrit-lexicon/Cologne/tree/master/api

This houses various documentations I have started regarding Clean URL development. You can copy paste rewrite rules from there and see whether it rolls out well.

@funderburkjim
Copy link
Contributor

Here is a way to get the whole url to be preprocessed by a php program ---

.htaccess

RewriteEngine On    # Turn on the rewriting engine
RewriteRule ^api/(.*)$ http://www.sanskrit-lexicon.uni-koeln.de/apitest/index.php?parms=$1

####php program apitest/index.php

<?php
/* Example from stackoverflow
http://stackoverflow.com/questions/6768793/get-the-full-url-in-php
$url =  "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
*/
$host = $_SERVER['HTTP_HOST'];
$uri = $_SERVER['REQUEST_URI'];
$parmstring = preg_replace('/.*?parms=/','',$uri);
$parms = explode('/',$parmstring);
//

list($display,$dict,$input,$key1,$output,$accentcode) = $parms;
$year = '2014';
$dictup = strtoupper($dict);

if ($accentcode == 'ignoreaccent') {
 $accent = 'off';
}else {
 $accent = 'on';
}
$newurl = sprintf("http://www.sanskrit-lexicon.uni-koeln.de/scans/%sScan/%s/web/webtc/getword.php?key=%s&filter=%s&noLit=off&transLit=%s",$dictup,$year,$key1,$output,$input);
// redirect. THIS MUST BE FIRST OUTPUT
header('Location:'.$newurl);
//displayinfo($host,$uri,$parmstring,$parms,$newurl);
function displayinfo($host,$uri,$parmstring,$parms,$newurl) {
echo  "HTTP_HOST=$host<br/>REQUEST_URI=$uri<br/>";
echo "parmstring=$parmstring<br/>";
for($i=0;$i<count($parms);$i++) {
 $val = $parms[$i];
 echo "parms[$i]=$val<br/>";
}
echo "newurl=$newurl<br/>";
}

?>

calling sequence

http://www.sanskrit-lexicon.uni-koeln.de/apitest/api/entries/PW/slp1/citra/deva/ignoreaccent

or lower case pw
http://www.sanskrit-lexicon.uni-koeln.de/apitest/api/entries/pw/slp1/citra/deva/ignoreaccent

This index.php program could probably be quite elaborate.

@funderburkjim
Copy link
Contributor

Address-bar problem

One thing that is undesireable in these approaches is that the browser address-bar gets changed to
the ?x=y&z=w form --- In other words, the original desired calling sequence gets clobbered.

e.g., for the first example, the address bar changes to the rewritten form:

http://www.sanskrit-lexicon.uni-koeln.de/scans/PWScan/2014/web/webtc/getword.php?key=citra&filter=deva&noLit=off&transLit=slp1

Is there some remedy for this?

@funderburkjim
Copy link
Contributor

comment on the input parameters

  • The parameters used in the examples thus far (in the expanded form) are
    key, filter,noLit,transLit
  • These are old forms; it is better to use
    key, output,<noLit not supported now- don't use', input
    So the above example becomes ( I changed values just to show things work):
http://www.sanskrit-lexicon.uni-koeln.de/scans/PWScan/2014/web/webtc/getword.php?key=aGga&output=roman&input=hk

@gasyoun
Copy link
Member

gasyoun commented Apr 20, 2017

Doable, but seems non-intuitive.

At least it's short and SEO is kept in mind.

Because

http://www.sanskrit-lexicon.uni-koeln.de/apitest/api/entries/pw/slp1/citra/deva/ignoreaccent

8 levels deep - we'll have indexation issues. I would want people to find not only the main page, but to find us googling for words as well.

Is there some remedy for this?

Did not get the question? Get rid of ? or what?

@drdhaval2785
Copy link
Contributor Author

drdhaval2785 commented Apr 23, 2017

Address-bar problem

Tried to do some research.

  1. Enable proxy module on apache2

    1. sudo a2enmod proxy_http
    2. sudo a2enmod proxy
    3. sudo service apache2 restart
  2. Add [P] flag at the end

At the end of it all, .htaccess reads like this

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteEngine on
RewriteRule ^suggest/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*) http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc2/query.php?word=&lastLnum=0&max=$5&filter=deva&regexp=exact&scase=true&sword=$4&sregexp=$2&transLit=$3&outopt=outopt4&swordhw=hwonly [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=$4&noLit=off&accent=$5&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=$4&noLit=off&accent=$5&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=$4&noLit=off&accent=no&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=$4&noLit=off&accent=no&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=slp1 [P]
RewriteRule ^entries/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=slp1 [P]
RewriteRule ^pdf/([^/]*)/word/([^/]*)$/ http://www.sanskrit-lexicon.uni-koeln.de/scans/awork/apidev/servepdf.php?dict=$1&key=$2 [P]
RewriteRule ^pdf/([^/]*)/word/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/awork/apidev/servepdf.php?dict=$1&key=$2 [P]
RewriteRule ^pdf/([^/]*)/page/([^/]*)$/ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/servepdf.php?page=$2 [P]
RewriteRule ^pdf/([^/]*)/page/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/servepdf.php?page=$2 [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=$5&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=$5&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=deva&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=deva&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=slp1&serverOptions=deva&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=slp1&serverOptions=deva&accent=no&viewAs=phonetic [P]

@vvasuki
Copy link
Collaborator

vvasuki commented Jun 4, 2017

This is a splendid project, gentlemen! @drdhaval2785 informed me about it on the https://groups.google.com/forum/#!topic/sanskrit-programmers/wdhMuXGpc1E thread, where I announced a similar API for all the dicts available with the stardict-sanskrit etc. projects.

Some suggestions from my experience (see links in thread above) is that in terms of rapid development and maintainability (without sacrificing any of the frontend-backend separation):

  • The JSON data of course, has to be created and ready. (You should transform all your xml-s to JSON-lists - Reminiscent of an earlier suggestion at Integrate Cologne dictionaries with stardict-updater #98 (comment) . Much better for downstream consumers.).
  • Simply put the data in a couchdb and make appropriate indices. The REST API comes automatically, and you get other benefits like easy replication. (I could help you with setting up this, if the data is ready.) For this, you don't have to write a single line of code (no reinventing the wheel), but you will have to compropmise on the nice intuitive api structure you have for something potentially more powerful.

That apart, some other feedback:

  • The JSON response structure in https://github.com/sanskrit-lexicon/Cologne/blob/master/api/getword.md:
    • A single dictionary entry may mention many synonyms - good to have a separate field for it (we use a headwords field).
    • why have the text only bit as well as html? It's rather easy to strip out the html tags at the client's end..
    • Indeed, why HTML necessarily? The entry's essential structure: bullet points, paragraph separation, footnotes can be stored. Always separate out presentation issues from more basic structure..
    • It is a good idea to group related fields together. Eg. Only { headwords, entries, dictLocation } at the top, with dictLocation having other stuff like {image, entryNumber, dictionaryId etc..} (as done here)
  • @drdhaval2785 , http://www.sanskrit-lexicon.uni-koeln.de/apitest/entries/PW/slp1/citra/deva/ignoreaccent is redirecting to some other page which is not returning a JSON result.
  • @funderburkjim I read somewhere that you've got some react+reflux UI. @kakella was doing something similar to use the API we've got. Could you point me to it?

PS:

  • I've recently improved and published a java stardict library, which can be used to write a superior android client which would directly read JSON structure and provide a better display.
  • @funderburkjim would it be possible to replicate our couchdb database on your servers? That way, we have more replication (be more robust to failure and getting booted otu) and potentially provide faster service. The UI can living on github pages etc.. can talk to whatever backend db is available.

@drdhaval2785
Copy link
Contributor Author

drdhaval2785 commented Jun 4, 2017

couchdb

some starters may help.

@drdhaval2785
Copy link
Contributor Author

but you will have to compropmise on the nice intuitive api structure

Not possible to have best of both worlds?

@drdhaval2785 , http://www.sanskrit-lexicon.uni-koeln.de/apitest/entries/PW/slp1/citra/deva/ignoreaccent is redirecting to some other page which is not returning a JSON result.

It is not yet configured to return JSON yet. I have currently piggybacked by rewrites on present Cologne scripts (which are made to return HTML). SO the documentation is ready. Rewrites are ready. Minor modifications on backend script or a version thereof is pending which returns JSON instead of HTML. That part is majorly Jim's lookout.

@vvasuki
Copy link
Collaborator

vvasuki commented Jun 4, 2017

some starters may help.

@drdhaval2785 http://docs.couchdb.org/en/2.0.0/contents.html has a good intro. I found it quite simple to setup and use.

(One another thing I like about couchdb is that you can replicate the db in couchbase-lite db files for offline use is mobiles etc..)

Not possible to have best of both worlds?

Certainly yes. Start with couchdb, write a very thin wrapper to translate the nice API you desire to the couchdb API while interacting with it. You might want to do it anyway to provide support for querying over ssl (ie https - couchdb2 is currently buggy there).

@mbykov
Copy link

mbykov commented Jun 4, 2017 via email

@artforlife
Copy link

Here is a way to get the whole url to be preprocessed by a php program ---

.htaccess

RewriteEngine On    # Turn on the rewriting engine
RewriteRule ^api/(.*)$ http://www.sanskrit-lexicon.uni-koeln.de/apitest/index.php?parms=$1

####php program apitest/index.php

<?php
/* Example from stackoverflow
http://stackoverflow.com/questions/6768793/get-the-full-url-in-php
$url =  "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
*/
$host = $_SERVER['HTTP_HOST'];
$uri = $_SERVER['REQUEST_URI'];
$parmstring = preg_replace('/.*?parms=/','',$uri);
$parms = explode('/',$parmstring);
//

list($display,$dict,$input,$key1,$output,$accentcode) = $parms;
$year = '2014';
$dictup = strtoupper($dict);

if ($accentcode == 'ignoreaccent') {
 $accent = 'off';
}else {
 $accent = 'on';
}
$newurl = sprintf("http://www.sanskrit-lexicon.uni-koeln.de/scans/%sScan/%s/web/webtc/getword.php?key=%s&filter=%s&noLit=off&transLit=%s",$dictup,$year,$key1,$output,$input);
// redirect. THIS MUST BE FIRST OUTPUT
header('Location:'.$newurl);
//displayinfo($host,$uri,$parmstring,$parms,$newurl);
function displayinfo($host,$uri,$parmstring,$parms,$newurl) {
echo  "HTTP_HOST=$host<br/>REQUEST_URI=$uri<br/>";
echo "parmstring=$parmstring<br/>";
for($i=0;$i<count($parms);$i++) {
 $val = $parms[$i];
 echo "parms[$i]=$val<br/>";
}
echo "newurl=$newurl<br/>";
}

?>

calling sequence

http://www.sanskrit-lexicon.uni-koeln.de/apitest/api/entries/PW/slp1/citra/deva/ignoreaccent

or lower case pw
http://www.sanskrit-lexicon.uni-koeln.de/apitest/api/entries/pw/slp1/citra/deva/ignoreaccent

This index.php program could probably be quite elaborate.

Is it possible to add similar URL parsing to getword.php file? That is, we would pass a clean URL to that file, do the parsing there and use the needed parameters within the file, as needed? I have not seen the getword.php, but it seems that it would be a quick change to make.

Also, we could then have an Apache rewrite rule to point from this type of URL

http://www.sanskrit-lexicon.uni-koeln.de/apitest/api/entries/pw/slp1/citra/deva/ignoreaccent

to this type

https://www.sanskrit-lexicon.uni-koeln.de/scans/PWScan/2014/web/webtc/

That is, we may not need that intermediary index.php URL-parser at all if getword.php is doing its own URL parsing.

I maybe missing something since I have not seen any code, but it seems to be a way to go about doing it.

@gasyoun
Copy link
Member

gasyoun commented Feb 4, 2019

@funderburkjim and @drdhaval2785 let me introduce to you @artforlife Yakov, hope this time it's for real. He want's to see the frontend files (all of them) and I do not know how to help him with that. First of all getword.php, but after that he still will need access to the test server. Forgot if that was possible.

@funderburkjim
Copy link
Contributor

@gasyoun @artforlife

'frontend files'

See description of dictionary_init.sh.

This indicates how to get local version. Such as integrated with local XAMPP server.

Is this enough to get you started?

@gasyoun
Copy link
Member

gasyoun commented Feb 5, 2019

See description of dictionary_init.sh.

Thanks a lot, again.

Is this enough to get you started?

Hmm, no.

  1. some general Cologne programs - a perfect entering point. Where I can have all?

  2. dictionary_init.sh downloads a 'working environment' for a given dictionary - but where Yakov could download for local testing or one day update to a test server that you Jim can access?

  3. Where is getword.php ?

@funderburkjim
Copy link
Contributor

getword.php

In the current setup, there is a 'getword.php' in two places:

  • apidev (this is the parent directory used by the list-0.2s.html display )
  • web/webtc : There is a getword.php in this directory for each of the dictionaries.

Probably you want the apidev version.

Here's how to get apidev.

  • first, clone this git repository : https://github.com/funderburkjim/apidev.
    • be sure the name of the local folder is 'apidev'
  • Move this to your local 'cologne' directory: e.g. \c\xampp\htdocs\cologne\apidev

Now you can access getword:

image

Important Note: This display works for 'mw' because the web display for mw has also been installed: \c\xampp\htdocs\cologne\mw\web. If you don't have mw installed locally, you'll get a 'not found' message back from getword.

Is this enough to get you started? I've lost track of what you are trying to accomplish here.

@funderburkjim
Copy link
Contributor

php htaccess

Good Impression from first quick read of @artforlife 's notes . Will give it a try at Cologne when time permits.

@artforlife
Copy link

@funderburkjim Much appreciated. I shall try out your suggestions shortly and let you know how everything goes.

@artforlife
Copy link

artforlife commented Feb 6, 2019

@funderburkjim I was able to follow your directions; however, I cannot get the getword.php to look up words. Instead, I am getting the following output:

image

As you suggested, my directory structure looks like this:

- cologne 
  --- apidev
  --- mw

getword.php is not working from either apidev or mw/web/webtc.

If you have an idea of what I am missing, I'll be happy to hear it. Otherwise, I'll finish installing some tools and debug it tomorrow.

@gasyoun
Copy link
Member

gasyoun commented Feb 6, 2019

I'll finish installing some tools and debug it tomorrow

Seems it will go this way.

@artforlife
Copy link

I am in business.

image

@gasyoun
Copy link
Member

gasyoun commented Feb 7, 2019

@artforlife ok, so you've got it running. Everything needed for the rewrite rule testing?

@artforlife
Copy link

artforlife commented Feb 7, 2019

@artforlife ok, so you've got it running. Everything needed for the rewrite rule testing?

We shall see. I'll play with that next. Do we know what the general steps for committing and testing are?

@artforlife
Copy link

artforlife commented Feb 18, 2019

I have a local version working. I was able to simplify it and perform the entire thing using only the rewrite rules. No additional index.php was needed.

Here is how it works.

Inside the cologne directory, we have the following .htaccess file:

RewriteEngine On    # Turn on the rewriting engine
RewriteRule ^(api)/([^/]*)/([^/]*)/([^/]*)/([^/]*) apidev/getword.php?dict=$2&key=$3&input=$4&output=$5

As you can probably gather from the rewrite rule, our call to the API will need to look something like this: http://sites.dev/sanskrit-dict/cologne/api/mw/hari/slp1/iast

When executed in the browser, we get

screenshot from 2019-02-17 22-35-51

which is the same as the direct call

screenshot from 2019-02-17 22-41-07

There is a minor issue with styles not being applied, but I have not even cared to investigate. This is a POC (proof-of-concept) example rather than some polished, publishable snippet. Is this what we wanted to achieve?

@gasyoun
Copy link
Member

gasyoun commented Feb 18, 2019

@artforlife thanks. Please see #117 (comment) for comparison - a bigger list of possible URLs. And need to know your opinion on #117 (comment) as well.

The URL as you proposed is a possible solution. But there should be an alternative, twice shorter as described at #249 (comment) It's important.

@artforlife
Copy link

@funderburkjim, @gasyoun forwarded me your letter with "exercises." They seem straightforward. I have started on them, but need access to some repositories.

Here is what I sent to @gasyoun regarding this:

Regarding #1, I need access to the following repository from Jim: https://github.com/funderburkjim/apidev. That is the one to which I am trying to push from the server, to make sure the connection is set up properly.

Also, the DO server currently has the following in its /var/www/html/cologne/ directory:

apidev dictionary_init.sh hwnorm1c_init.sh sanhw1 test.php
apidev_init.sh gra mw test.html unixify.py

It is probably wise to ask Jim for access to the respective repositories as well. For example, I am pretty sure we will need it for "mw".

Could you help us with this? Let me know if you have questions about anything.

@artforlife
Copy link

Address-bar problem

Tried to do some research.

1. Enable proxy module on apache2
   
   1. sudo a2enmod proxy_http
   2. sudo a2enmod proxy
   3. sudo service apache2 restart

2. Add [P] flag at the end

At the end of it all, .htaccess reads like this

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteEngine on
RewriteRule ^suggest/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*) http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc2/query.php?word=&lastLnum=0&max=$5&filter=deva&regexp=exact&scase=true&sword=$4&sregexp=$2&transLit=$3&outopt=outopt4&swordhw=hwonly [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=$4&noLit=off&accent=$5&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=$4&noLit=off&accent=$5&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=$4&noLit=off&accent=no&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=$4&noLit=off&accent=no&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=$3 [P]
RewriteRule ^entries/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=slp1 [P]
RewriteRule ^entries/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=slp1 [P]
RewriteRule ^pdf/([^/]*)/word/([^/]*)$/ http://www.sanskrit-lexicon.uni-koeln.de/scans/awork/apidev/servepdf.php?dict=$1&key=$2 [P]
RewriteRule ^pdf/([^/]*)/word/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/awork/apidev/servepdf.php?dict=$1&key=$2 [P]
RewriteRule ^pdf/([^/]*)/page/([^/]*)$/ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/servepdf.php?page=$2 [P]
RewriteRule ^pdf/([^/]*)/page/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc/servepdf.php?page=$2 [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=$5&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=$5&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=deva&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=deva&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)/$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=slp1&serverOptions=deva&accent=no&viewAs=phonetic [P]
RewriteRule ^list/([^/]*)/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=slp1&serverOptions=deva&accent=no&viewAs=phonetic [P]

Are these URLs still current? Is this where we would like to go?

Is it possible to get sample calls for each URL on this list? That is, I would like a call with real-life parameters for each end-point, so I can test it locally and then on the testing server.

@drdhaval2785
Copy link
Contributor Author

The URLs are still current.
I am not sure whether we want to reach there or not. Marcis had strong reservations against long URLs. So it is not yet decided.

If you can shorten the left side of equations, better. Right side links mostly work.

word = rAma
dict = MW
translit = slp1

These seem to be reasonable parameters

@artforlife
Copy link

http://localhost/apitrial/entries/PW/slp1/citra/deva/ignoreaccent

I would go for http://www.sanskrit-lexicon.uni-koeln.de/MD/citra/SDI/
instead of http://www.sanskrit-lexicon.uni-koeln.de/scans/MDScan/2014/web/webtc/indexcaller.php

/SDI/

These service pages we will close for indexation. S for SLP1, D for devanagari, I for ignore accents.

I propose we do a two-stage roll-out. First, we implement URLs in their longer version. Once that is done, we can shorten them to the format you advocate. We should at least do this at the testing stage. This way it will be easier to control what we want and make changes. Once URL sequences are set, the shortening of words should be straightforward. The deployment to production can be done with the final version.

@drdhaval2785
Copy link
Contributor Author

drdhaval2785 commented Mar 6, 2019 via email

@artforlife
Copy link

@drdhaval2785 , @gasyoun , I am attaching the list of URLs as it appears to me after I parsed it and went over it. I would like you to double check it. I am particularly interested in knowing how you envision the calls to be made. Those are presented in the form of comments above each rewrite rule. Let us spec those out properly. Furthermore, the ones marked with a question mark deserve a closer look for one reason or another.

If I am missing something or if there are inaccuracies, let us clarify them before I move on with further work.

# 1. /suggest/sregexp/transLit/sword/max/
RewriteRule ^suggest/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*) http://www.sanskrit-lexicon.uni-koeln.de/scans/$1Scan/2014/web/webtc2/query.php?word=&lastLnum=0&max=$5&filter=deva&regexp=exact&scase=true&sword=$4&sregexp=$2&transLit=$3&outopt=outopt4&swordhw=hwonly [P]

# 2.a. /entries/key/transLit/filter/accent/
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)/$ apidev/getword.php?key=$2&filter=$4&noLit=off&accent=$5&transLit=$3 [P]

# 2.b. /entries/key/transLit/filter/accent
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)$ apidev/getword.php?key=$2&filter=$4&noLit=off&accent=$5&transLit=$3 [P]

# 3.a. /entries/key/transLit/filter/
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ apidev/getword.php?key=$2&filter=$4&noLit=off&accent=no&transLit=$3 [P]

# 3.b. /entries/key/transLit/filter
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ apidev/getword.php?key=$2&filter=$4&noLit=off&accent=no&transLit=$3 [P]

# 4.a /entries/key/transLit/
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)/$ apidev/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=$3 [P]

# 4.b. /entries/key/transLit/
RewriteRule ^entries/([^/]*)/([^/]*)/([^/]*)$ apidev/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=$3 [P]

# 5.a. /entries/key/
RewriteRule ^entries/([^/]*)/([^/]*)/$ apidev/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=slp1 [P]

# 5.b. /entries/key
RewriteRule ^entries/([^/]*)/([^/]*)$ apidev/getword.php?key=$2&filter=deva&noLit=off&accent=no&transLit=slp1 [P]

# 6.a. /pdf/dict/word/key/
RewriteRule ^pdf/([^/]*)/word/([^/]*)$/ http://www.sanskrit-lexicon.uni-koeln.de/scans/awork/apidev/servepdf.php?dict=$1&key=$2 [P]

# 6.b. /pdf/dict/word/key
RewriteRule ^pdf/([^/]*)/word/([^/]*)$ http://www.sanskrit-lexicon.uni-koeln.de/scans/awork/apidev/servepdf.php?dict=$1&key=$2 [P]

# 7.a.(?) /pdf/page-variable/page/whatevs/
RewriteRule ^pdf/([^/]*)/page/([^/]*)$/ apidev/servepdf.php?page=$2 [P]

# 7.b.(?) /pdf/page-variable/page/whatevs
RewriteRule ^pdf/([^/]*)/page/([^/]*)$ apidev/servepdf.php?page=$2 [P]

# 8.a. /list/key/phoneticInput/serverOptions/accent/
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)/$ apidev1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=$5&viewAs=phonetic [P]

# 8.b. /list/key/phoneticInput/serverOptions/accent
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]+)$ apidev1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=$5&viewAs=phonetic [P]

# 9.a. /list/key/phoneticInput/serverOptions/
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ apidev1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=no&viewAs=phonetic [P]

# 9.b. /list/key/phoneticInput/serverOptions
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ apidev1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=$4&accent=no&viewAs=phonetic [P]

# 10.a. /list/key/phoneticInput/
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)/$ apidev1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=deva&accent=no&viewAs=phonetic [P]

# 10.b. /list/key/phoneticInput
RewriteRule ^list/([^/]*)/([^/]*)/([^/]*)$ apidev1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=$3&serverOptions=deva&accent=no&viewAs=phonetic [P]

# 11.a. /list/key/
RewriteRule ^list/([^/]*)/([^/]*)/$ apidev1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=slp1&serverOptions=deva&accent=no&viewAs=phonetic [P]

# 11.b. /list/key
RewriteRule ^list/([^/]*)/([^/]*)$ apidev1/listhier.php?key=$2&keyboard=yes&inputType=phonetic&unicodeInput=devInscript&phoneticInput=slp1&serverOptions=deva&accent=no&viewAs=phonetic [P]

@gasyoun
Copy link
Member

gasyoun commented Mar 6, 2019

Marcis had strong reservations against long URLs.

And still has.

First, we implement URLs in their longer version.

Sure

word = rAma
dict = MW
translit = slp1

These seem to be reasonable parameters

slp1 is good for several reasons and should be used by default in generating the URLs. What I say is:

word = rAma
dict = MW

Should be enough. Actually even MW can be used by default, in this case we can have only

word = rAma

without accent.
The question is what should be the default display. SLP1 is good for URLs, but not for human reading. So display by default before choosing should be human readable - IAST or devanagari.

@artforlife
Copy link

artforlife commented Mar 8, 2019

Marcis had strong reservations against long URLs.

And still has.

First, we implement URLs in their longer version.

Sure

word = rAma
dict = MW
translit = slp1

These seem to be reasonable parameters

slp1 is good for several reasons and should be used by default in generating the URLs. What I say is:

word = rAma
dict = MW

Should be enough. Actually even MW can be used by default, in this case we can have only

word = rAma

without accent.
The question is what should be the default display. SLP1 is good for URLs, but not for human reading. So display by default before choosing should be human readable - IAST or devanagari.

What is key and what is filter?

Can you fill in the first call's parameters fully, as an example?

/entries/key/transLit/filter/accent/

Also, on all of these we seem to be missing the dictionary parameter. Is that expected? The toy-example I made above used it:
http://sites.dev/sanskrit-dict/cologne/api/mw/hari/slp1/iast

@gasyoun
Copy link
Member

gasyoun commented Mar 11, 2019

What is key and what is filter?

filter = output encoding for Sanskrit words
key = dictionary headword

Can you fill in the first call's parameters fully, as an example?

/entries/key/transLit/filter/accent/

Yakov's string contains 5 elements, but getword.php?key=citra&filter=iast&noLit=off&transLit=slp1 has only 5. Your /entries/ equals to scans/PWScan/2014/web/webtc/

So

/entries/key/transLit/filter/accent/

would be

/PW/citra/slp1/deva/ignoreaccent/

http://www.sanskrit-lexicon.uni-koeln.de/apitest/entries/PW/slp1/citra/deva/ignoreaccent

redirects to (and is still a working example)

https://www.sanskrit-lexicon.uni-koeln.de/scans/PWScan/2014/web/webtc/getword.php?key=citra&filter=deva&noLit=off&transLit=slp1

Also, on all of these we seem to be missing the dictionary parameter. Is that expected? The toy-example I made above used it:
http://sites.dev/sanskrit-dict/cologne/api/mw/hari/slp1/iast

As per seem to be missing the dictionary parameter - indeed, it's hidden inside scans/PWScan/2014/web/webtc/ and should it be a parameter at all? Not sure. I guess it would make sense to have such a parameter, than 33 real folders named after dicitonaries containing the index.php script doing the same job.

The only drawback seems to be the capital PW in the whole url. It is a bit difficult to modify it to lowercase in rewrite rule. Jim can handle it in backend. The dictionary code passed in small letters can be converted to capital on his part in PHP.

We will have capital letters in URL anyway, because SLP1 is the way I propose we code the key in URL string. So PW should not be an issue as well.

http://localhost/apitrial/entries/PW/slp1/citra/deva/ignoreaccent

@drdhaval2785 as stated bellow some thing can be taken for granted and should not be stated in all URLs. Instead of a long URL like the one quoted above I see:

http://localhost/apitrial/entries/PW/slp1/citra/

Where ignoreaccent is by deffault. If accent will be needed (we can add the field like a for accent). deva can be accepted as default as well. Althought slp1 could be taken away as well, leawing only dictionary and headword, we could play with capital letters in it.

SLP1
sLP1 - IAST output
slP1 - with accent
Slp1 -

And so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New website features
Projects
None yet
Development

No branches or pull requests

6 participants