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#!/usr/local/bin/python 

2# encoding: utf-8 

3""" 

4*Simple Login Page* 

5 

6:Author: 

7 David Young 

8""" 

9from builtins import object 

10import sys 

11import os 

12from fundamentals import tools, times 

13import khufu 

14 

15class login_page(object): 

16 """ 

17 *The worker class for the login_page module* 

18 

19 **Key Arguments** 

20 

21 - ``log`` -- logger 

22 - ``mainCssFilePath`` -- the filepath of the main CSS file 

23 - ``jsFilePath`` -- the filepath of the main JS file 

24 - ``pageTitle`` -- pageTitle 

25 - ``iconPath`` -- webapp icon path 

26 - ``came_from`` -- the url this login page was triggered from 

27 - ``message`` -- message to display as notification 

28  

29 """ 

30 

31 def __init__( 

32 self, 

33 log, 

34 mainCssFilePath="/static/styles/main.css", 

35 jsFilePath="/static/js/main-ck.js", 

36 pageTitle="Login", 

37 iconPath="", 

38 came_from="/", 

39 message="" 

40 ): 

41 self.log = log 

42 log.debug("instansiating a new 'login_page' object") 

43 self.mainCssFilePath = mainCssFilePath 

44 self.jsFilePath = jsFilePath 

45 self.pageTitle = pageTitle 

46 self.iconPath = iconPath 

47 self.came_from = came_from 

48 self.message = message 

49 

50 # xt-self-arg-tmpx 

51 

52 # create the form 

53 formContent = khufu.forms.login_form( 

54 self.log, 

55 self.iconPath, 

56 self.message 

57 ) 

58 self.formContent = formContent.get() 

59 self.webapge = self._build_webapge_scaffolding() 

60 

61 return None 

62 

63 def close(self): 

64 del self 

65 return None 

66 

67 def get(self): 

68 """ 

69 *get the login_page object* 

70 

71 **Return** 

72 

73 - ``login_page`` -- the html login page 

74  

75 """ 

76 self.log.debug('starting the ``get`` method') 

77 

78 # CREATE THE WEBPAGE 

79 login_page = self.webapge 

80 # CLEAR MESSAGE 

81 self.message = "" 

82 

83 self.log.debug('completed the ``get`` method') 

84 return login_page 

85 

86 def _build_webapge_scaffolding( 

87 self): 

88 """ 

89 *build webapge scaffolding* 

90 

91 **Key Arguments** 

92 

93  

94 

95 **Return** 

96 

97 - ``webpage`` -- the html login page 

98  

99 """ 

100 self.log.debug('starting the ``_build_webapge_scaffolding`` method') 

101 

102 head = khufu.head( 

103 relativeUrlBase=False, 

104 mainCssFilePath=self.mainCssFilePath, 

105 pageTitle=self.pageTitle, 

106 extras='' 

107 ) 

108 

109 pageContent = khufu.grid_row( 

110 responsive=True, 

111 columns=self.formContent, 

112 htmlId="login_row", 

113 htmlClass=False, 

114 onPhone=True, 

115 onTablet=True, 

116 onDesktop=True 

117 ) 

118 

119 body = khufu.body( 

120 navBar=False, 

121 content=pageContent, 

122 htmlId='', 

123 extraAttr='', 

124 relativeUrlBase=False, 

125 responsive=True, 

126 googleAnalyticsCode=False, 

127 jsFilePath=self.jsFilePath 

128 ) 

129 

130 webpage = khufu.htmlDocument( 

131 contentType=False, 

132 content="%(head)s %(body)s" % locals() 

133 ) 

134 

135 self.log.debug('completed the ``_build_webapge_scaffolding`` method') 

136 return webpage