Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - TPJ

#1
newLISP in the real world / Re: Uploading files problem
November 11, 2010, 01:34:40 AM
Thanks for your remarks. Using write-file is not a solution, since I'm working on a web application. My only option is to use the POST method.





I'll start with a little update. I've been trying to solve that problem for two days now (spending on it my full time), and I've made some interesting observations:



1) Reading the stdin from a newLISP CGI script works perfectly, as long as a text file is uploaded. It works perfectly in both cases: when using nginx as a proxy, and without any proxy server.



2) Reading the stdin from a newLISP CGI script fails when a binary file is uploaded. After reading a few bytes, the stdin suddenly breakes. Once again: it happens in both cases: with ngxinx proxy, and without it.



I have described this problem http://stackoverflow.com/questions/4133870/uploading-binary-files-problem">here, on stackoverflow (you can check there what exactly I get from stdin in my scripts). The proposed solution didn't help, though. But let's forget about this problem, for a while.



I decided to investigate it more. I've installed the http://www.acme.com/software/thttpd/">thttpd server, and used it to perform the same task: serve two pages, one upload.html, and one CGI script, that should just read the stdin and save it to some file. I used a simple shell script to do the job:



#!/bin/sh

cat > to-file

echo -e "Content-type: text/htmlrnrn"
echo "<p>Hello!</p>"


The result: everything ran fine, just as it should. I was able to upload any file I wanted.



So, I tried to do the same thing using the newLISP HTTP server, and exactly the same two pages (including the simple shell script). The result: all binary files uploaded were broken, just as in the first case I described in this post.



I'm not an HTTP server expert... Therefore I hope that my conclusion is wrong. But the conclusion is that something is wrong with the newLISP HTTP server - since it's the only thing that had been changed before everything stopped to work correctly. And I don't like this conclusion, since I intend to use the newLISP HTTP server a lot.



I tested it all on my Arch Linux box, if it is of any importance.
#2
newLISP in the real world / Uploading files problem
November 09, 2010, 01:58:20 AM
I have a web app written in newLISP. The app is served by the newLISP interpreter run in the HTTP server mode. The server runs behind a proxy, which is nginx. So the flow is simple: nginx gets the requests, and proxies it to the newLISP HTTP server.



I have problems with files uploading. The script mentioned in http://newlispfanclub.alh.net/forum/viewtopic.php?f=2&t=2585">this topic doesn't work, since no CONTENT_LENGTH (or CONTENT_TYPE) environment variable is set (I checked it). BTW, I used the upload.html code to perform all tests.



I tried to just read the stdin, but it doesn't work. My CGI scripts (pure newLISP) get nothing to read (stdin is empty).



When I tried to reach the newLISP HTTP server directly (without nginx serving as a proxy), I was able to upload a text file. I just used a simple script, that reads stdin, and gets all the content of the sent file:



(set 'infile (open "upload-file" "write"))
(while (read (device) buffer 1024)
  (write infile buffer))
(close infile)


Unfortunatelly, sending any binary file (e.g. images) doesn't work at all. The stdin is broken after a few bytes read. For example, in case of a GIF image, all I got was:


-----------------------------1124875958105779246987104586
Content-Disposition: form-data; name="uploaded_data"; filename="polsl.gif"
Content-Type: image/gif

GIF89a_




Now, the questions.



1) Why on earth my script doesn't get anything on stdin when newLISP HTTP server is run behind a proxy (nginx in my case)?

2) Why on earth binary files aren't properly sent, while text files are?



I'll appreciate any help.
#3
Well, I used to use (g)vim for newLISP files too. The problem was I was missing features from DrRacket. And since (g)vim is written in C/C++ (I'm not sure, whether it's C or C++), and jEdit is written in Java, and since I like Java much much more than C/C++, I eventually decided to develop my plugin.



Right now, I have to stop development for a few days (I hope this pause won't get longer!), because I have other things to do (I'm going to test the plugin in that time). I set up the plugin's http://www.tprimke.net/blog_it/?page_id=66">page, I added some features, and options (so you won't have to deal with my default settings).



If you used only vim before, I really encourage you to try jEdit together with LispMode (and newlisp mode for files - right now it's neccessary for LispMode to work!). You'll get a convenient list of functions (and their subfunctions) for navigation, form highlighting, and better indentation. (Well - at least for me, but my usage of vim was always at the basic level...)



More features to come... as well as support for more Lisp dialects.
#4
Anything else we might add? / jEdit plugin for newLISP
November 02, 2010, 05:02:46 AM
Some time ago I started to work on a http://www.tprimke.net/public/LispMode.jar">jEdit plugin for newLISP (and, probably, other Lisp dialects) source files editing. The plugin is still in its alpha stage, and I'm still learning how to write jEdit plugins, but on the other side, some features are already working:

- functions' list is displayed (the list might be used to navigate the source file)

- smart indenting after the ENTER key was pressed

- forms are highlighted while the cursor is moved

- incomplete form brackets are also highlighted (in red) while the cursor is moved



The plugin still needs a lot of work to be completed. All the features have to be improved. Besides, so far my only motivation for developing this plugin was my need for such a tool. Thus, the plugin is adapted to MY personal needs and habits.



The good news is: you can use the plugin, if you'd like to.



The bad news:

- The plugin has been hardly tested. It shoudn't delete your files, nor crash you computer. It's possible, though, that the features won't be working as they should. (I'll appreciate any bug reports!)

- So far, I've had time to work on the plugin. Development take me more and more time, though. It's possible, that in the future I'll have to focus on other tasks, and I'll work on the plugin after hours. It'll slow down the development.



Anyway, if you like the plugin, and if you'd like to propose some features, please let me know.



Oh, and one more thing. Right now, the plugin works only for buffers which use the http://www.newlisp.org/code/jedit-newlisp-mode-generator.lsp.html">newlisp jEdit mode.



For all interested: to install the plugin, just download the linked file and place it in the directory, where jEdit keeps its plugins (if you use jEdit, you will know where it is).
#5
I've finally found some time to document my changes and to prepare http://www.tprimke.net/public/toc_rename.patch">a patch. I'll e-mail Lutz.



If someone is interested in what I did, here's some documentation:



[*] http://www.tprimke.net/blog_it/?p=24">table of contents [/*]
  • [*] http://www.tprimke.net/blog_it/?p=36">rename pages [/*]

  • [/list]
    #6
    newLISP in the real world / newLISP wiki features
    June 23, 2010, 11:13:21 PM
    I'm interested in using newLISP wiki (actually, I've been using it for a month). I find it a great piece of software, although I'd like it have some additional features. My first candidate is table of contents, known from Wikipedia (useful on long pages). Is anywhere some roadmap for this project available? Or, perhaps, would it be possible to send some patch for such features (yes, I can implement them on my own)?