Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# CREATED : 20130508 

2from builtins import range 

3from khufu import images 

4 

5def mediaObject( 

6 displayType='div', 

7 imagePath='', 

8 headlineText='', 

9 otherContent=False, 

10 nestedMediaObjects=False, 

11): 

12 """ *Generate an abstract object style for building various types of components (like blog comments, Tweets, etc) that feature a left- or right-aligned image alongside textual content.* 

13 

14 **Key Arguments** 

15 

16 - ``displayType`` -- the display style of the media object [ "div" | "li" ] 

17 - ``img`` -- the image to include 

18 - ``headlineText`` -- the headline text for the object 

19 - ``otherContent`` -- other content to be displayed inside the media object 

20 - ``nestedMediaObjects`` -- nested media objects to be appended 

21  

22 

23 **Return** 

24 

25 - ``media`` -- the media object """ 

26 

27 

28 falseList = [nestedMediaObjects] 

29 

30 for i in range(len(falseList)): 

31 if not falseList[i]: 

32 falseList[i] = "" 

33 

34 [nestedMediaObjects] = falseList 

35 

36 if not otherContent: 

37 otherContent = "" 

38 

39 thisImage = images.image( 

40 src=imagePath, # [ industrial | gray | social ] 

41 href=False, 

42 display="polaroid", # [ rounded | circle | polaroid | False ] 

43 pull="left", # [ "left" | "right" | "center" | False ] 

44 htmlClass=False, 

45 width=False 

46 ) 

47 

48 thisImage = """<img src="%(imagePath)s" class="pull-left" style="width: 128px;">""" % locals( 

49 ) 

50 

51 thisImage = images.image( 

52 src=imagePath, 

53 href=imagePath, 

54 display="polaroid", # [ rounded | circle | polaroid ] 

55 pull="left", # [ "left" | "right" | "center" ] 

56 htmlClass=False, 

57 htmlId=False, 

58 thumbnail=True, 

59 width=150, 

60 height=False, 

61 ) 

62 

63 mediaObject = \ 

64 """ 

65 <%(displayType)s class="media" id=" "> 

66 %(thisImage)s 

67 <div class="media-body"> 

68 <h4 class="media-heading">%(headlineText)s</h4> 

69 %(otherContent)s 

70 <!-- Nested media object --> 

71 %(nestedMediaObjects)s 

72 </div> 

73 </%(displayType)s>""" \ 

74 % locals() 

75 return mediaObject