Better handling of maxLength and HTML

- Don't truncate before HTML conversion
- Correctly calculate indexed chars and total chars
- Move HTML conversion code into one function
Order by clientDateModified DESC when getting content to upload

This way content from newly added/modified items will get uploaded
before content from older items.