Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign & modernise CSS, add Google Analytics option, other miscellaneous improvements. #1

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SchemaSpy - Prettified

This repository contains a custom version of [SchemaSpy](http://schemaspy.sourceforge.net/) customised with a number of features and enhancements not found in the original project.

## Features and enhancements

- A modern stylesheet for screen and print based on Foundation (no more lime green - yay!)
- Responsive design, including the removal of many layout tables.
- The '-showanomalies' flag, which makes the 'anomalies' tab visible. The default is now false.
- Make comments visible by default
- The '-ga' flag, which lets you specify a Google Analytics tracking code to include in all output
- The '-showdbname' flag, which shows the database schema name in table descriptions. The default is now false.
- The donation links have been removed. There is still a link to the SchemaSpy website.

## Screenshot

![SchemaSpy screenshot](schemaspy-foundation-example.png)

## Credits and acknowledgements

- The [SchemaSpy project](http://schemaspy.sourceforge.net/) and its creator, John Currier
- [Kuali](https://github.com/kuali/schemaspy), who forked the original project and packaged it as a Maven artefact
- Foundation and its components:
- [Placeholder.js](http://mths.be/placeholder) - MIT licence
- [Normalize.css](https://github.com/necolas/normalize.css) - MIT licence
- [Modernizr.js](http://www.modernizr.com) - BSD and MIT licence
- [JQuery](http://jquery.com/) - MIT licence
- My agent

## Licence

[LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html), like SchemaSpy.

## Contact

Graeme West (see commits for email address).
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<encoding>${project.encoding}</encoding>
<debug>true</debug>
<debuglevel>source,lines</debuglevel>
<compilerArgument>-Xlint:unchecked</compilerArgument>
</configuration>
</plugin>
<plugin>
Expand Down
Binary file added schemaspy-foundation-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 54 additions & 1 deletion src/main/java/net/sourceforge/schemaspy/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public class Config
private boolean hasOrphans = false;
private boolean hasRoutines = false;
private boolean populating = false;
private Boolean showAnomalies;
private Boolean showDBName;
private String googleAnalyticsID;
private List<String> columnDetails;
public static final String DOT_CHARSET = "UTF-8";
private static final String ESCAPED_EQUALS = "\\=";
Expand Down Expand Up @@ -558,6 +561,19 @@ public String getDriverPath() {
return driverPath;
}

public void setGoogleAnalyticsID(String googleAnalyticsID) {
this.googleAnalyticsID = googleAnalyticsID;
}

public String getGoogleAnalyticsID() {
if (googleAnalyticsID == null)
googleAnalyticsID = pullParam("-ga");
if (googleAnalyticsID == null)
googleAnalyticsID = "";

return googleAnalyticsID;
}

/**
* The filename of the cascading style sheet to use.
* Note that this file is parsed and used to determine characteristics
Expand Down Expand Up @@ -788,6 +804,37 @@ public boolean isEncodeCommentsEnabled() {
return encodeCommentsEnabled;
}


/**
* Show DB structure anomalies. Defaults to false.
*/
public void setAnomaliesEnabled(boolean enabled) {
showAnomalies = enabled;
}

public boolean isAnomaliesEnabled() {
if (showAnomalies == null)
showAnomalies = !options.remove("-showanomalies");

return showAnomalies;

}

/**
* Show the database name in descriptions/titles. Defaults to false.
*/
public void setDBNameEnabled(boolean enabled) {
showDBName = enabled;
}

public boolean isDBNameEnabled() {
if (showDBName == null)
showDBName = !options.remove("-showdbname");

return showDBName;

}

/**
* If enabled we'll attempt to query/render the number of rows that
* each table contains.
Expand Down Expand Up @@ -1756,12 +1803,18 @@ public List<String> asList() throws IOException {
params.add("-sso");
if (isSchemaDisabled())
params.add("-noschema");
if(isAnomaliesEnabled())
params.add("-showanomalies");
if(isDBNameEnabled())
params.add("-showdbname");

String value = getDriverPath();
if (value != null) {
params.add("-dp");
params.add(value);
}
params.add("-ga");
params.add(getGoogleAnalyticsID());
params.add("-css");
params.add(getCss());
params.add("-charset");
Expand Down Expand Up @@ -1872,4 +1925,4 @@ public List<String> asList() throws IOException {

return params;
}
}
}
7 changes: 5 additions & 2 deletions src/main/java/net/sourceforge/schemaspy/SchemaAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,11 @@ public Database analyze(Config config, ProgressListener progressListener) throws
logger.info("Writing/graphing summary");

ImageWriter.getInstance().writeImages(outputDir);
ResourceWriter.getInstance().writeResource("/jquery.js", new File(outputDir, "/jquery.js"));
ResourceWriter.getInstance().writeResource("/schemaSpy.js", new File(outputDir, "/schemaSpy.js"));
ResourceWriter.getInstance().writeResource("/js/vendor/jquery.js", new File(outputDir, "/js/vendor/jquery.js"));
ResourceWriter.getInstance().writeResource("/js/schemaspy/schemaSpy.js", new File(outputDir, "/js/schemaspy/schemaSpy.js"));
ResourceWriter.getInstance().writeResource("/css/normalize.css", new File(outputDir, "/css/normalize.css"));
ResourceWriter.getInstance().writeResource("/css/foundation.css", new File(outputDir, "/css/foundation.css"));
ResourceWriter.getInstance().writeResource("/schemaSpy-print.css", new File(outputDir, "/schemaSpy-print.css"));

progressListener.graphingSummaryProgressed();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ private void writeHeader(String diagramName, boolean showLabel, LineWriter dot)
if (rankdirbug)
dot.writeln(" label=\"\\nLayout is significantly better without '-rankdirbug' option\"");
else
dot.writeln(" label=\"\\nGenerated by SchemaSpy\"");
dot.writeln(" labeljust=\"l\"");
}
dot.writeln(" nodesep=\"0.18\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void writeImpliedConstraints(List<? extends ForeignKeyConstraint> implie
}

if (numDetected > 0) {
out.writeln("<table class='dataTable' border='1' rules='groups'>");
out.writeln("<table class='dataTable' rules='groups'>");
out.writeln("<colgroup>");
out.writeln("<colgroup>");
out.writeln("<thead align='left'>");
Expand Down Expand Up @@ -139,7 +139,7 @@ private void writeTablesWithoutIndexes(List<Table> unindexedTables, LineWriter o
out.writeln("<li>");
out.writeln("<b>Tables without indexes:</b>");
if (!unindexedTables.isEmpty()) {
out.writeln("<table class='dataTable' border='1' rules='groups'>");
out.writeln("<table class='dataTable' rules='groups'>");
out.writeln("<colgroup>");
if (displayNumRows)
out.writeln("<colgroup>");
Expand Down Expand Up @@ -215,7 +215,7 @@ private void writeTablesWithOneColumn(List<Table> tables, LineWriter out) throws
out.writeln("<li>");
out.write("<b>Tables that contain a single column:</b>");
if (!tables.isEmpty()) {
out.writeln("<table class='dataTable' border='1' rules='groups'>");
out.writeln("<table class='dataTable' rules='groups'>");
out.writeln("<colgroup>");
out.writeln("<colgroup>");
out.writeln("<thead align='left'>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void write(Database database, Collection<Table> tables, ColumnInfo column
private void writeHeader(Database db, int numberOfColumns, ColumnInfo selectedColumn, LineWriter html) throws IOException {
writeHeader(db, null, "Columns", html);

html.writeln("<table width='100%' border='0'>");
html.writeln("<table width='100%'>");
html.writeln("<tr><td class='container'>");
writeGeneratedOn(db.getConnectTime(), html);
html.writeln("</td><td class='container' rowspan='2' align='right' valign='top'>");
Expand All @@ -168,8 +168,8 @@ private void writeHeader(Database db, int numberOfColumns, ColumnInfo selectedCo
html.writeln("<p>");
html.writeln("<form name='options' action=''>");
if (Config.getInstance().getColumnDetails().contains("comments"))
html.writeln(" <label for='showComments'><input type=checkbox id='showComments'>Comments</label>");
html.writeln(" <label for='showLegend'><input type=checkbox checked id='showLegend'>Legend</label>");
html.writeln(" <input type=checkbox id='showComments'><label for='showComments'>Comments</label>");
html.writeln(" <input type=checkbox checked id='showLegend'><label for='showLegend'>Legend</label>");
html.writeln("</form>");
html.writeln("</table>");

Expand All @@ -196,7 +196,7 @@ public void writeMainTableHeader(boolean hasTableIds, ColumnInfo selectedColumn,
boolean onColumnsPage = selectedColumn != null;
List<String> details = null;
out.writeln("<a name='columns'></a>");
out.writeln("<table id='columns' class='dataTable' border='1' rules='groups'>");
out.writeln("<table id='columns' class='dataTable' rules='groups'>");

if (onColumnsPage) {
details = new ArrayList<String>(Config.getInstance().getColumnDetails());
Expand Down Expand Up @@ -452,4 +452,4 @@ public int compare(TableColumn column1, TableColumn column2) {
return rc;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void writeForeignKeyConstraints(List<ForeignKeyConstraint> constraints,
html.writeln(" <a href='http://sourceforge.net' target='_blank'><img src='http://sourceforge.net/sflogo.php?group_id=137197&amp;type=1' alt='SourceForge.net' border='0' height='31' width='88'></a>");
html.writeln("</td></tr>");
html.writeln("</table><br>");
html.writeln("<table class='dataTable' border='1' rules='groups'>");
html.writeln("<table class='dataTable' rules='groups'>");
html.writeln("<colgroup>");
html.writeln("<colgroup>");
html.writeln("<colgroup>");
Expand Down Expand Up @@ -251,4 +251,4 @@ private int writeCheckConstraints(Table table, LineWriter html) throws IOExcepti
protected boolean isConstraintsPage() {
return true;
}
}
}
Loading