Skip to content

Commit

Permalink
Merge pull request #30 from yast/erb_summary
Browse files Browse the repository at this point in the history
use an ERB template for rendering AutoYast summary
  • Loading branch information
lslezak committed Mar 26, 2014
2 parents 1f08d61 + 1267efd commit cf0ede4
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 68 deletions.
7 changes: 7 additions & 0 deletions package/yast2-registration.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Mar 25 17:38:37 UTC 2014 - lslezak@suse.cz

- use an ERB template instead of ugly Summary module for rendering
AutoYast rich text summary
- 3.1.23

-------------------------------------------------------------------
Tue Mar 25 09:25:38 UTC 2014 - lslezak@suse.cz

Expand Down
9 changes: 5 additions & 4 deletions package/yast2-registration.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 3.1.22
Version: 3.1.23
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down Expand Up @@ -70,10 +70,11 @@ Authors:
%defattr(-,root,root)
%{yast_desktopdir}/customer_center.desktop
%{yast_clientdir}/*.rb
%{yast_ydatadir}/registration
%{yast_schemadir}/autoyast/rnc/*.rnc
%{yast_dir}/lib/registration
%{yast_dir}/lib/yast
%{yast_dir}/lib/yast/scc_api.rb
%{yast_libdir}/registration
%{yast_libdir}/yast
%{yast_libdir}/yast/scc_api.rb
%doc %{yast_docdir}

%changelog
6 changes: 5 additions & 1 deletion src/Makefile.am
Expand Up @@ -28,6 +28,10 @@ schemafilesdir = $(schemadir)/autoyast/rnc
schemafiles_DATA = \
autoyast-rnc/registration.rnc

EXTRA_DIST = $(client_DATA) $(desktop_DATA) $(ylib_DATA) $(ylibyast_DATA) $(schemafiles_DATA)
ydatadir = @ydatadir@/registration
ydata_DATA = \
data/registration/summary.erb

EXTRA_DIST = $(client_DATA) $(desktop_DATA) $(ylib_DATA) $(ylibyast_DATA) $(schemafiles_DATA) $(ydata_DATA)

include $(top_srcdir)/Makefile.am.common
73 changes: 10 additions & 63 deletions src/clients/scc_auto.rb
Expand Up @@ -27,13 +27,15 @@
#

require "yast/scc_api"
require "erb"

require "registration/storage"
require "registration/registration"

module Yast
class SccAutoClient < Client
include Yast::Logger
include ERB::Util

def main
Yast.import "UI"
Expand All @@ -44,7 +46,6 @@ def main
Yast.import "Wizard"
Yast.import "Label"
Yast.import "Report"
Yast.import "Summary"
Yast.import "Popup"
Yast.import "Sequencer"

Expand Down Expand Up @@ -116,71 +117,17 @@ def export
end


# Create a textual summary and a list of unconfigured cards
# return summary of the current configuration
# Create a textual summary
# @return [String] summary of the current configuration
def summary
summary = ""
# use erb template for rendering the richtext summary
erb_file = File.expand_path("../../data/registration/summary.erb", __FILE__)

# Translators: Heading - capitalized
summary = Summary.AddHeader(summary, _("Product Registration"))
log.info "Loading ERB template #{erb_file}"
erb = ERB.new(File.read(erb_file))

summary = Summary.OpenList(summary)
summary = Summary.AddListItem(summary,
@config.do_registration ?
_("Run registration during autoinstallation") :
_("Skip registration during autoinstallation")
)
summary = Summary.CloseList(summary)

# registration disabled, no summary details needed
return summary unless @config.do_registration

summary = Summary.AddHeader(summary, _("Registration Settings"))
summary = Summary.OpenList(summary)
summary = Summary.AddListItem(summary, _("Email: %s") % @config.email)

if @config.reg_key && !@config.reg_key.empty?
summary = Summary.AddListItem(summary, _("Registration Key: <em>Configured</em>"))
end

if @config.install_updates
summary = Summary.AddListItem(summary, _("Install Available Patches"))
end

summary = Summary.CloseList(summary)

if (@config.reg_server && !@config.reg_server.empty?) || (@config.slp_discovery)
summary = Summary.AddHeader(summary, _("Registration Server Settings"))
summary = Summary.OpenList(summary)

if !@config.reg_server.empty?
summary = Summary.AddListItem(summary, (_("Server URL: %s") % @config.reg_server))
end

if @config.slp_discovery
summary = Summary.AddListItem(summary, _("Server URL: %s") % _("Use SLP discovery"))
end

if @config.reg_server_cert && !@config.reg_server.empty?
summary = Summary.AddListItem(
summary,
_("Server Certificate: %s") % @config.reg_server_cert
)
end
summary = Summary.CloseList(summary)
end

if !@config.addons.empty?
summary = Summary.AddHeader(summary, _("Addon Products"))
summary = Summary.OpenList(summary)

@config.addons.each do |addon|
summary = Summary.AddListItem(summary, addon["name"])
end
summary = Summary.CloseList(summary)
end

summary
# render the ERB template in the context of the current object
erb.result(binding)
end

# register the system, base product and optional addons
Expand Down
48 changes: 48 additions & 0 deletions src/data/registration/summary.erb
@@ -0,0 +1,48 @@
<%
=begin the textdomain for y2makepot
textdomain "registration"
=end
%>

<h3><%= _("Product Registration") %></h3>
<ul>
<li>
<%= @config.do_registration ?
_("Run registration during autoinstallation") :
_("Skip registration during autoinstallation") %>
</li>
</ul>

<% if @config.do_registration %>
<h3><%= _("Registration Settings") %></h3>
<ul>
<li><%= _("Email: %s") % h(@config.email) %></li>
<% if !@config.reg_key.empty? %>
<li><%= _("Registration Key is Configured") %></li>
<% end %>
<% if @config.install_updates %>
<li><%= _("Install Available Patches") %></li>
<% end %>
</ul>

<h3><%= _("Registration Server") %></h3>
<ul>
<% if !@config.reg_server.empty? %>
<li><%= _("Server URL: %s") % h(@config.reg_server) %></li>
<% elsif @config.slp_discovery %>
<li><%= (_("Server URL: %s") % _("Use SLP discovery")) %></li>
<% end %>
<% if !@config.reg_server_cert.empty? %>
<li><%= _("Server Certificate: %s") % h(@config.reg_server_cert) %></li>
<% end %>
</ul>

<h3><%= _("Addon Products") %></h3>
<ul>
<% @config.addons.each do |addon| %>
<li><%= h(addon["name"]) %></li>
<% end %>
</ul>
<% end %>

0 comments on commit cf0ede4

Please sign in to comment.