[Site] CSS per la stampa

Stefano e.tino a email.it
Dom 16 Lug 2006 00:26:25 CEST


Manlio Perillo ha scritto:
> Ho appena notato che il sito python.org ha un foglio di stile specifico
> per la stampa.
> 
> <link media="print" href="styles/print.css" type="text/css"
> rel="stylesheet" />
> 
> Stefano, lo potresti importare?
> 

Fatto. Ti allego la patch da applicare. La modifica ha interessato anche 
  PDONewGenerator.py per poter aggiungere nell'header anche i 
riferimenti al foglio di stile per la stampa.

Visto che c'ero ho aggiunto anche il link alla favicon.

Inoltre ho modifico il foglio di stile print.css. Per ora l'ho testato 
solo con firefox, potrebbe dare problemi con altri browser specialmente 
con quelli pił datati.

Saluti
Stefano
-------------- parte successiva --------------
Index: python.it/styles/print.css
===================================================================
--- python.it/styles/print.css	(revision 193)
+++ python.it/styles/print.css	(working copy)
@@ -1,31 +1,79 @@
-#left-hand-navigation, #google, #document-navigation, #border-corner, #smallcorner, #searchcorner, #logo, #search, #utility-menu, #skiptonav
-{
-  display:none;
-}
-
-#content-body
-{
-  font-family: Georgia, "Bitstream Vera Serif", "New York", Palatino, serif;
-  font-size:11pt;
-}
-
-#content-body a
-{
-  color: #000000;
-  text-decoration:none;
-}
-
-#body-main a
-{
-  font-weight:bold;
-}
-
-#body-main a:after
-{
-   content: " (" attr(href) ") ";
-}
-
-h1
-{
-  font-size:14pt;
-}
+/*
+ * Stylesheet for python.org.  This is (mostly) empty for now, since
+ * not all of the site actually references it.  Styles can be added
+ * once more of the HTML on the site includes the relevant <link>
+ * element.
+ *
+ * Documentation for the named classes will be made available at
+ * http://www.python.org/dev/pydotorg/ once this isn't an empty
+ * stylesheet.
+ */
+
+ 
+body {
+	font-family: avantgard, sans-serif;
+	margin: 0;
+	padding: 0;
+}
+
+#page {
+
+} 
+
+#banner {
+	display:none;
+}
+
+#logolink {
+	display:none;
+}
+
+
+#quote {
+	display:none;
+	}
+	
+#sidebar {
+	display:none;
+}
+
+#body {
+	display: block;
+	width: 95%;
+	float: left;
+	font-size: 0.9em;
+	font-family: Arial,Verdana,Geneva,"Bitstream Vera Sans",Helvetica,sans-serif;
+	line-height: 1.4em;
+}
+
+#body:after {
+	content: ".";
+	display:block;
+	height: 0;
+	clear:both;
+	visibility: hidden;
+}
+
+#page:after {
+	content: ".";
+	display:block;
+	height: 0;
+	clear:both;
+	visibility: hidden;
+}
+ 
+h1, h2, h3, h4, h5
+{
+	font-family: Georgia,"Bitstream Vera Serif","New York",Palatino,serif;
+	font-weight: normal;
+	font-size: 1.6em;
+}
+
+
+/* This avoids the white border around the page in MSIE. */
+html                 { border: 0px;
+                       margin: 0px;
+                       padding: 0px; }
+
+.continuation        { margin-left: 1em;
+                       margin-right: 1em; }
Index: scripts/ht2html/PDONewGenerator.py
===================================================================
--- scripts/ht2html/PDONewGenerator.py	(revision 193)
+++ scripts/ht2html/PDONewGenerator.py	(working copy)
@@ -197,18 +197,32 @@
     def __do_styles(self):
         # assemble all the style information we have to produce the
         # appropriate LINK and STYLE elements
-        stylesheet = self.get_stylesheet()
+        stylesheet = self.get_stylesheet()
+        #~ added css reference for print media
+        printsheet = self.get_printsheet()
+        #~ added referce for favicon
+        favicon = self.get_favicon()
         localstyle = self.get_style()
         s = ''
         if stylesheet and stylesheet.strip():
             stylesheet = stylesheet.strip()
             type = self.get_stylesheet_type(stylesheet)
-            s = '<link rel="stylesheet" href="%s" type="%s">' \
-                % (stylesheet, type)
+            s = '<link rel="stylesheet" href="%s" type="%s" media="screen">\n' \
+                % (stylesheet, type)
+        #~ added css reference for print media
+        if printsheet and printsheet.strip():
+            printsheet = printsheet.strip()
+            type = self.get_stylesheet_type(printsheet)
+            s = s + '<link rel="stylesheet" href="%s" type="%s" media="print">\n' \
+                %(printsheet, type)
+        if favicon and favicon.strip():
+            favicon = favicon.strip()
+            s = s + '<link rel="shortcut icon" type="image/ico" href="%s" />\n'\
+                %(favicon)
         if localstyle and localstyle.strip():
             localstyle = '<style type="text/css">\n%s\n</style>' \
                          % localstyle.strip()
-            if stylesheet:
+            if stylesheet or printsheet:
                 s = s + "\n" + localstyle
             else:
                 s = localstyle
@@ -414,7 +428,14 @@
 
     def get_stylesheet(self):
         #~ return posixpath.join('/style.css')
-        return posixpath.join(self.__d['rootdir'], 'styles/style.css')
+        return posixpath.join(self.__d['rootdir'], 'styles/style.css')
+        
+    def get_printsheet(self):
+        #~ return stylesheet for print media called by SkeletronCSS.__do_style()
+        return posixpath.join(self.__d['rootdir'], 'styles/print.css')
+    def get_favicon(self):
+        #~ return favicon reference
+        return posixpath.join(self.__d['rootdir'], 'styles/favicon.ico')
 
     def get_title(self):
         return self.__parser.get('title')


Maggiori informazioni sulla lista Site