Wednesday, June 8, 2011

Autocomplete for tags added

My Question on Support site for LampCMS project

OK, as per some requests I added the autocomplete for tags
After applying a quick fix to YUI tag widget it works well now.

You can try it here for yourself here, post some question with some existing tags.

If everything works well and there are not more bugs discovered here then I'll push this to github.

Click here to post your reply


Tuesday, June 7, 2011

My answer to "xml markup in editor and (maybe) preview"

This is my answer to a Question on Support site for LampCMS project


There are no limitations. Your users can even use Code highleghter to treat your code snippets as XML, for examle like this: (just highlight code and select "Code style" in the editor


<xsl:template match="/">
        <xsl:element name="plaintext">
                <xsl:apply-templates />
        </xsl:element>
</xsl:template>

My answer to "What attachments beyond images and YouTube are supported?"

This is my answer to a Question on Support site for LampCMS project


Text file? Why don't you just post it as text?
Right now there is no option to attach any files. Even image and youtube options are not really an attachments but simply point to external images or video.

I plan on adding uploader option to the RTE editor but was only going to allow image uploads, have not thought about attachments really.


Monday, June 6, 2011

My answer to "Is there any way to include images in my post?"

This is my answer to a Question on Support site for LampCMS project


There are some posts with images on this site. I am not sure how they did it. There is no support to actually save an image to the server but there is a way to just include an img tag that points to image hosted somewhere else. 

Sunday, June 5, 2011

Lampcms REST API preview

My Question on Support site for LampCMS project

Hello!

Just want to let you know the status of the API work. Here is what I wrote so far:

Wrote base class for the API, wrote a new type of class called Output. This represents the content that is ready to be sent out to the client and it specific to the output format. Concrete classes representing the output format like Json or XML or Jsonp extend this class.

Wrote the Response class - it represents the body and headers ready to be sent to the client (usually browser but any API client really)

Added a new section to !config.ini called [API]

It has these params:
; Maximum results an API can return per page
MAX_RESULTS = 100
; Dalily access limit for not logged in users
DAILY_LIMIT_ANON = 150
; Daily access limit for logged in users
DAILY_LIMIT_APP = 3000
; Daily limit for authenticated user
DAILY_LIMIT_USER = 10000


Using these settings you can completely restring the access to API to only your partner sites by settings DAILY_LIMIT_ANON = 0
It will prevent any access by anonymous clients


API already supports these basic features: makes use of Http response headers and specific HTTP status codes. For example 404 when content not fount or 406 when the value of request parameter is invalid or 500 in case of error in API

Support for custom headers to indicate client's daily rate limit:
X-RateLimit-Limit
X-RateLimit-Remaining
X-RateLimit-Reset
The X-RateLimit-Reset is the timestamp of the next time limit is reset which is usually the beginning of the next day since rate limit is per day.

API currently supports 2 output formats: JSON and JSONP
support for XML can easily be added by just writing the custom OutputXML class. No changes to other classes will be necessary.

API has support for versioning. This is how most good APIs work - when new version of API is released the old ones still work, so your client programs are not broken. You can just pass the v (version id) in request and start using the new version of API. Current version is 1

Currently I wrote 2 API controllers: questions and question

This is how you use it:
Example URL for api is: domain/api/api.php?v=1&a=questions&start_id=5&limit=1&sort=i_votes&dir=desc&alt=json

Here is the explanation of params:

v = version of API, optional, defaults to 1, so for now you can omit it as 1 is the only version

a = "action" Currently completed controllers for "questions" and "question" actions

limit = number of results to return per API call. Think of it as a per-page number on the website.
sort = sort results by this param. For "questions" allowed values are i_votes to sort by votes,
i_lm_ts to sort by "last modified timestamp",
_id to sort by question id,
i_ans to sort by number of answers

dir = direction of sorting. Allowed values are asc for ascending or desc for descending (default)

start_id = show questions with id greated than this (but not including this) id.

max_id = show questions with id less than but not including this id

starttime = unix timestamp in GMT. Show questions posted after this time

tags = space separated tags. Request must be urlencoded so space char should be replaced with %20
show only questions with these tags

match = when tags value is set you can use this param to set to "all" or "any" to match questions with any of the tags or to return questions that must contain all of the tags

uid = userID. Return only questions posted by this user.

type = Return only questions of this type. Allowed values are: "unans" to return only questions with no answers,
"answrd" to return questions with answers by not with "Accepted" answer, "accptd" to return only questions that have an "Accepted" answer.

Extra params: comments=yes to also include comments (by default comments not included)
body=yes to also include full body of question. By default only the "intro", a short text-only version of the first 150 chars of question is included

You can mix these params. For example you can easily get only unanswered questions that have certain tags and posted after certain time.


Question controller.

This controller returns data for one question specified by the qid param.
Example : domain/api/api.php?a=question&qid=5&sort=i_votes&limit=4

Here the limit applies to number of Answers included in response.
For Question controller you can also sort by "accepted", for example: sort=accepted&limit=1
will return only 1 answer that is an "Accepted" answer.


For both questions and question controllers the returned data includes number of total results and the pageID.
Default pageid = 1, you can pass the pageID in request in order to get questions that did not fit in the per-page limit and you know that are more results. In such cases you use the pagination by passing pageID value


You can review the source files for more info. API classes are in /lib/Lampcms/Api/ folder

More API controllers will be released soon: tags, tag, users, user, answers
As well as web controller to register the client and to get clientID.







Click here to post your reply


Saturday, June 4, 2011

My answer to "autocomplete search not including tags"

This is my answer to a Question on Support site for LampCMS project


Yes, definetely I want to add autocomplete for the tags field too. In fact if you dig through my Javascript code you will find that it was actually added but then commented out.
The reason for that is that autocomplete for tags has a bug. I use the YUI tag widget written by one of the YUI team member and when I discovered that bug in autocomplete I contacted him and he basically promised to fix it. So as soon as it's fixed I will add auto complete for tags back.

My answer to "two word tags"

This is my answer to a Question on Support site for LampCMS project


I personally think 2-word tags is not a good idea. I thought about it but I don't remember exact reason why I decided the 2-words tags are bad idea, but at that time there was a good reason for that. One reason is it makes it easier for end-user to enter tags and now worry about forgetting to include comma.

As far as comma separated - yes, currently comma could be used as well as space.
For 2-word tags you would have to use underscore or dashed between words.

The Good thing about tags on this site is that any char is allowed in tags, including UTF-8 char, so even non-English alphabet could be used in tags. This support for Unicode chars in tags is a big deal, this feature is not supported on many other Q&A sites. Also even non-letters like % are allowed in tags, so a 100% would be a valid tag.