コード例 #1
0
 def test_checkExample(self):
     self.assertEqual(mf2tojf2.mf2tojf2(
         {
           "items": [
             {
               "type": [
                 "h-entry"
               ],
               "properties": {
                 "author": [
                   {
                     "type": [
                       "h-card"
                     ],
                     "properties": {
                       "name": [
                         "A. Developer"
                       ],
                       "url": [
                         "http://example.com"
                       ]
                     },
                     "value": "A. Developer"
                   }
                 ],
                 "name": [
                   "Hello World"
                 ],
                 "summary": [
                   "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus imperdiet ultrices pulvinar."
                 ],
                 "url": [
                   "http://example.com/2015/10/21"
                 ],
                 "published": [
                   "2015-10-21T12:00:00-0700"
                 ],
                 "content": [
                   {
                     "html": "<p>Donec dapibus enim lacus, <i>a vehicula magna bibendum non</i>. Phasellus id lacinia felis, vitae pellentesque enim. Sed at quam dui. Suspendisse accumsan, est id pulvinar consequat, urna ex tincidunt enim, nec sodales lectus nulla et augue. Cras venenatis vehicula molestie. Donec sagittis elit orci, sit amet egestas ex pharetra in.</p>",
                     "value": "Donec dapibus enim lacus, a vehicula magna bibendum non. Phasellus id lacinia felis, vitae pellentesque enim. Sed at quam dui. Suspendisse accumsan, est id pulvinar consequat, urna ex tincidunt enim, nec sodales lectus nulla et augue. Cras venenatis vehicula molestie. Donec sagittis elit orci, sit amet egestas ex pharetra in."
                   }
                 ]
               }
             }
           ]
         }), 
         {
           "type": "entry",
           "author": {
             "type": "card",
             "url": "http://example.com",
             "name": "A. Developer"
           },
           "url": "http://example.com/2015/10/21",
           "published": "2015-10-21T12:00:00-0700",
           "name": "Hello World",
           "summary": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus imperdiet ultrices pulvinar.",
           "content": "Donec dapibus enim lacus, a vehicula magna bibendum non. Phasellus id lacinia felis, vitae pellentesque enim. Sed at quam dui. Suspendisse accumsan, est id pulvinar consequat, urna ex tincidunt enim, nec sodales lectus nulla et augue. Cras venenatis vehicula molestie. Donec sagittis elit orci, sit amet egestas ex pharetra in."
         })
コード例 #2
0
 def test_checkHentry1Tag(self):
      self.assertEqual(mf2tojf2.mf2tojf2({"items":[{"type": ["h-entry"], "properties": 
      { "name": ["entry with tags"], "category": ["tagged"]}}]}), 
         {
         "type": "entry",
         "name": "entry with tags",
         "category": "tagged"
         })
コード例 #3
0
 def test_checkFlatHentry(self):
      self.assertEqual(mf2tojf2.mf2tojf2({"items":[{"type": ["h-entry"], "properties": {"url": ["http://kevinmarks.com/hwc2015-06-17.html"], "name": ["Homebrew Website Club notes 2015-06-17"], "published": ["2015-06-17"]}}]}), 
         {
         "type": "entry",
         "published": "2015-06-17",
         "name": "Homebrew Website Club notes 2015-06-17",
         "url": "http://kevinmarks.com/hwc2015-06-17.html"
         })
コード例 #4
0
 def test_checkHentryTextAuthor(self):
      self.assertEqual(mf2tojf2.mf2tojf2({"items":[{"type": ["h-entry"], "properties": 
             {"author":["fred bloggs"],
              "name": ["Homebrew Website Club"]}}]}), 
         {
         "type": "entry",
         "name": "Homebrew Website Club",
         "author":"fred bloggs",
         })
コード例 #5
0
 def test_checkHentryeContent(self):
      self.assertEqual(mf2tojf2.mf2tojf2({"items":[{"type": ["h-entry"], "properties": 
             {"content":[{"html":"<p>this is <b>content</b>","value":"this is content"}],
              "name": ["Homebrew Website Club"]}}]}), 
         {
         "type": "entry",
         "name": "Homebrew Website Club",
         "content": "this is content"
         })
コード例 #6
0
 def test_bareEntries(self):
      self.assertEqual(mf2tojf2.mf2tojf2({"items":[
             {"type":["h-entry"],"properties":{"name":["bare post"]}},
             {"type":["h-entry"],"properties":{"name":["longer bare post"]}},
             ]}), 
         {
         "children":[
             {"type":"entry","name":"bare post"},
             {"type":"entry","name":"longer bare post"},
             ],
         })
コード例 #7
0
 def test_checkHfeedChildEntry(self):
      self.assertEqual(mf2tojf2.mf2tojf2({"items":[{"type": ["h-feed"], 
      "children":[{"type":["h-entry"],"properties":{"name":["short post"]}}], "properties": 
             {"author":[{"type":["h-card"],"properties": {"name":["fred blog"]}}],
              "name": ["Homebrew Website Club"]}}]}), 
         {
         "type": "feed",
         "name": "Homebrew Website Club",
         "author": {"type":"card", "name":"fred blog",},
         "children":[
             {"type":"entry","name":"short post"}
             ],
         })
コード例 #8
0
 def get(self):
     url = fixurl(self.request.get('url'))
     prettyText = self.request.get('pretty','')
     pretty = prettyText == 'on'
     result = urlfetch.fetch(url)
     if result.status_code == 200:
         data= json.loads(result.content)
         jf2 = mf2tojf2.mf2tojf2(data)
         if pretty:
             jf2json = json.dumps(jf2,indent=4, separators=(', ', ': '))
         else:
             jf2json = json.dumps(jf2)
         self.response.headers['Content-Type'] = 'application/json'
         self.response.write(jf2json)
コード例 #9
0
 def test_checkEmptyItems(self):
     self.assertEqual(mf2tojf2.mf2tojf2({"items":[]}), {})
コード例 #10
0
 def test_checkEmpty(self):
     self.assertEqual(mf2tojf2.mf2tojf2({}), {})
コード例 #11
0
 def test_checkEmptyHentry(self):
      self.assertEqual(mf2tojf2.mf2tojf2({"items":[{"type":["h-entry"]}]}), {'type':'entry'})
コード例 #12
0
ファイル: main.py プロジェクト: kevinmarks/mentiontech
def htmltomfjf(html,url,mf2=None):
    if not mf2:
        mf2 = mf2py.Parser(html, url).to_dict()
    jf2 = mf2tojf2.mf2tojf2(mf2)
    return mf2,jf2
コード例 #13
0
def htmltomfjf(html,url,mf2=None):
    if not mf2:
        mf2 = mf2py.Parser(html, url).to_dict()
    jf2 = mf2tojf2.mf2tojf2(mf2)
    return mf2,jf2