2013-08-23

TinyMCEエディタにマークアップした初期値を表示

TinyMCE4で、HTMLをエディタの初期値に表示する方法。下書き保存とかした内容を再編集するさいに必要になる。
こんな感じにやればいいっぽい。

<script type="text/javascript">
        tinymce.init({
            selector: "textarea",
         });
        tinymce.on("AddEditor", function(e) {
            tinyMCE.activeEditor.on("init", function(event) {
                tinyMCE.activeEditor.setContent("<h1>見出し</h1>テキスト");
            });
        });
    </script>

djangoで使おうと思って、プラグインを導入した方がいいのか迷ったんだけど、管理者サイトで使うのでなければテンプレートでJavaScriptを編集するの良さそう。

2013-08-17

User-Agentに漢字が混ざっててエラー

djangoだと、request.META.get("HTTP_USER_AGENT", "") ってやってUser-Agentを取得できる。django1.3.1を使っているんだけど、ユニコードではなくて、バイト文字列が返されるみたい。普通はASCII文字以外は含まれていないから問題ないんだけど、中国とかベトナムからのアクセスだと、User-Agentに漢字などが含まれているものがあって、それが原因でエラーになってた。
request.META.get("HTTP_USER_AGENT", "").decode("utf-8")
ってやればたぶん大丈夫。

こんなのがある。

Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; W1+(MT6589/4核) Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

Mozilla/5.0 (Linux; U; Android 4.1.2; vi-vn; IM-A830K Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Điện thoạiSafari/534.30

Mozilla/5.0 (Linux; U; Android 4.0.4; zh-cn; A10双核(8DM1) Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30

Gmailの連絡先エクスポートについて

Gmailの連絡先エクスポートについての公式ヘルプはこちら。https://support.google.com/mail/answer/24911?hl=ja

エクスポートの形式は3つある。
  1. Google CSV形式
  2. Outlook CSV形式
  3. vCard形式
Google CSV形式

文字コードはUTF-8。「google.csv」という名前のファイルがダウロードされる。CSVのカラムは次のとおり。
Name
Given Name
Additional Name
Family Name
Yomi Name
Given Name Yomi
Additional Name Yomi
Family Name Yomi
Name Prefix
Name Suffix
Initials
Nickname
Short Name
Maiden Name
Birthday
Gender
Location
Billing Information
Directory Server
Mileage
Occupation
Hobby
Sensitivity
Priority
Subject
Notes
Group Membership
E-mail 1 - Type
E-mail 1 - Value
E-mail 2 - Type
E-mail 2 - Value
IM 1 - Type
IM 1 - Service
IM 1 - Value
Phone 1 - Type
Phone 1 - Value
Phone 2 - Type
Phone 2 - Value
Phone 3 - Type
Phone 3 - Value
Phone 4 - Type
Phone 4 - Value
Address 1 - Type
Address 1 - Formatted
Address 1 - Street
Address 1 - City
Address 1 - PO Box
Address 1 - Region
Address 1 - Postal Code
Address 1 - Country
Address 1 - Extended Address
Organization 1 - Type
Organization 1 - Name
Organization 1 - Yomi Name
Organization 1 - Title
Organization 1 - Department
Organization 1 - Symbol
Organization 1 - Location
Organization 1 - Job Description
Website 1 - Type
Website 1 - Value
Outlook CSV形式
文字コードはShift_JIS。contacts.csvというファイル名でダウンロードされる。カラムは次のとおり。
First Name
Middle Name
Last Name
Title
Suffix
Initials
Web Page
Gender
Birthday
Anniversary
Location
Language
Internet Free Busy
Notes
E-mail Address
E-mail 2 Address
E-mail 3 Address
Primary Phone
Home Phone
Home Phone 2
Mobile Phone
Pager
Home Fax
Home Address
Home Street
Home Street 2
Home Street 3
Home Address PO Box
Home City
Home State
Home Postal Code
Home Country
Spouse
Children
Manager's Name
Assistant's Name
Referred By
Company Main Phone
Business Phone
Business Phone 2
Business Fax
Assistant's Phone
Company
Job Title
Department
Office Location
Organizational ID Number
Profession
Account
Business Address
Business Street
Business Street 2
Business Street 3
Business Address PO Box
Business City
Business State
Business Postal Code
Business Country
Other Phone
Other Fax
Other Address
Other Street
Other Street 2
Other Street 3
Other Address PO Box
Other City
Other State
Other Postal Code
Other Country
Callback
Car Phone
ISDN
Radio Phone
TTY/TDD Phone
Telex
User 1
User 2
User 3
User 4
Keywords
Mileage
Hobby
Billing Information
Directory Server
Sensitivity
Priority
Private
Categories

vCard
文字コードはUTF-8。http://en.wikipedia.org/wiki/VCard

Proguard: can't find referenced method 'void setPluginsEnabled(boolean)' in class android.webkit.WebSettings

Androidでproguard使ってたら、こんなエラーがでた。
[2013-08-17 00:00:00 - MyApp] Proguard returned with error code 1. See console
[2013-08-17 00:00:00 - MyApp] Note: there were 3594 duplicate class definitions.
[2013-08-17 00:00:00 - MyApp] Warning: jp.co.cayto.appc.sdk.android.AppCWebActivity: can't find referenced method 'void setPluginsEnabled(boolean)' in class android.webkit.WebSettings
[2013-08-17 00:00:00 - MyApp]       You should check if you need to specify additional program jars.
[2013-08-17 00:00:00 - MyApp] Warning: there were 1 unresolved references to program class members.
[2013-08-17 00:00:00 - MyApp]          Your input classes appear to be inconsistent.
[2013-08-17 00:00:00 - MyApp]          You may need to recompile them and try again.
[2013-08-17 00:00:00 - MyApp]          Alternatively, you may have to specify the option
[2013-08-17 00:00:00 - MyApp]          '-dontskipnonpubliclibraryclassmembers'.
[2013-08-17 00:00:00 - MyApp] java.io.IOException: Please correct the above warnings first.
[2013-08-17 00:00:00 - MyApp]     at proguard.Initializer.execute(Initializer.java:321)
[2013-08-17 00:00:00 - MyApp]     at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-08-17 00:00:00 - MyApp]     at proguard.ProGuard.execute(ProGuard.java:86)
[2013-08-17 00:00:00 - MyApp]     at proguard.ProGuard.main(ProGuard.java:492)


proguardの設定ファイルに、
-keep public class android.webkit.WebSettings { *;}
って追加したら直ったみたい。
たぶん、古いバージョンのAndroidでも動くように、組み込んだjarでリフレクション使ってるからエラーになったのだろう。